Skip to content

feat: add wp spacefast WP-CLI commands - #18

Open
mvanhorn wants to merge 1 commit into
spacefast:mainfrom
mvanhorn:fix/wordpress-wp-cli
Open

mvanhorn wants to merge 1 commit into
spacefast:mainfrom
mvanhorn:fix/wordpress-wp-cli

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

Publishing to Spacefast was only possible from wp-admin buttons. Now a shell or deploy script can do it with wp spacefast:

wp spacefast status [--format=table|json]
wp spacefast publish [--wait] [--timeout=<s>]
wp spacefast build [--wait]
wp spacefast sync-settings
wp spacefast disconnect [--yes]

With --wait, publish blocks until the version is live and exits non-zero on failure or timeout.

Why this matters

Publishing to Spacefast from WordPress only works from wp-admin buttons, and the plugin registers no WP-CLI command. A host, an agency's deploy script, CI or a coding agent can't publish after a content import without driving a browser. With these commands it's one shell call whose exit code a script can trust.

Demo

Simulated demo (HyperFrames), built from a real run: Docker WordPress with Simply Static 3.8.25, connected to a Spacefast Space:

demo

Changes

The manual admin actions move into shared methods with no nonce or redirect handling, and the admin_post_* handlers become thin wrappers around them, so wp-admin behaves exactly as before. The commands live in a new includes/class-spacefast-cli.php, registered only when WP_CLI is defined. status reads saved state and never prints credentials.

publish --wait runs Simply Static's export tasks inline through a small Archive_Creation_Job subclass, so a publish finishes without WP-Cron or loopback requests. On timeout, the remaining work goes back to the normal background worker, so nothing is lost.

The inline worker yields between tasks but has to respect Simply Static's own limits inside a task. In 3.8.x, fetch_urls asks should_continue before every page, and returning false there fetched nothing. My first live run sat at "Fetched 0 of 1356" until it timed out. The fix and a regression test are included.

The README and readme.txt get a "Command line" section, and the version is 0.6.0 with a changelog entry.

Testing

bin/test.sh behavior tests pass, including the per-task yield. bin/test-wordpress.sh passes both container suites; the WP-CLI suite installs Simply Static 3.8.0 and runs status --format=json and publish --wait against the injected transport.

Live, I edited a page and ran wp spacefast publish --wait. It took 39 seconds and exited 0. wp spacefast status then showed state live with the new version ID, and the public page had the edit.

This touches files that open #13, #15 and #16 also change (the client, publisher and plugin bootstrap), so I'll rebase after whichever lands first. The 0.6.0 bump may need renumbering.


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • Added WP-CLI commands to check connection and build status, publish, build, sync settings, and disconnect.
    • Publish and build commands can wait for completion. Publish supports a configurable timeout, and commands support selecting a site on multisite installations.
    • Status information can be displayed as a table or JSON.
  • Documentation
    • Added command usage, wait behavior, timeout limits, and multisite guidance.
  • Release
    • Updated the plugin version to 0.6.0.

Add status, publish, build, sync-settings and disconnect commands so hosts,
agencies and deploy scripts can publish without wp-admin. The manual admin
actions move into shared methods that the admin handlers and the CLI both
call, so wp-admin behavior is unchanged.

publish --wait and build --wait block until the version is live or the
build succeeds and exit non-zero on failure or timeout. With --wait, Simply
Static's export tasks run inline, so a publish finishes without WP-Cron.
The inline worker yields between tasks but keeps Simply Static's own limits
inside a task, since fetch_urls checks should_continue before every page.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The plugin adds five WP-CLI commands for status, publishing, builds, settings synchronization, and disconnect. It adds reusable manual operations and supports waited publishing through inline Simply Static export processing. Documentation and acceptance tests cover the new commands.

Changes: WP-CLI command support

Layer / File(s) Summary
Reusable manual plugin actions
includes/class-spacefast-plugin.php, tests/behavior.php
Manual build, static publish, settings sync, and disconnect actions now use reusable operations that return structured results. Manual builds and publishes check their required modes and settings. Forced changes can be recorded even when a change was already recorded.
CLI commands and waited export processing
includes/class-spacefast-cli.php, includes/class-spacefast-cli-export-job.php, tests/behavior.php, tests/acceptance/wordpress.php, bin/test-wordpress.sh
The spacefast command provides status, publish, build, settings-sync, and disconnect operations. Waited publishing processes supported Simply Static jobs inline and checks delivery and activation state. Tests and acceptance checks exercise command results, timeouts, export processing, and disconnect behavior.
CLI registration and release documentation
spacefast-wordpress.php, README.md, readme.txt
The bootstrap loads the CLI class when WP_CLI is available. The plugin version changes to 0.6.0; the documentation describes commands, wait behavior, timeout options, and multisite site selection.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant WPCLI as WP-CLI
  participant SpacefastCLI as Spacefast_CLI
  participant Plugin as Spacefast_Plugin
  participant SimplyStatic as Simply Static
  participant SpacefastAPI as Spacefast API
  WPCLI->>SpacefastCLI: invoke publish --wait
  SpacefastCLI->>Plugin: start manual static publish
  Plugin->>SimplyStatic: start export
  SpacefastCLI->>SimplyStatic: advance inline export job
  SpacefastCLI->>SpacefastAPI: check delivery and activation
  SpacefastAPI-->>SpacefastCLI: return generation state
  SpacefastCLI-->>WPCLI: report completion or failure
Loading

Suggested reviewers: batuhan

Merge Risk: Low · up to e1aee

The new CLI commands look sound overall. In a narrow case, build --wait can exit 0 for a failed build if a content edit lands between status checks. This is worth knowing about but is not a merge blocker.

Security architecture risk: Minimal · up to e1aee

The inspected changes preserve existing web permissions and exclude credentials from status output. No introduced security or material failure-containment defect was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The new operational authority reaches production publishing, builds, settings updates and connection removal for the selected WordPress installation. It reuses stored Spacefast authorization rather than granting a new remote identity. Effective credential scope still depends on the existing OAuth grant.

Trust Boundaries and Controls

  • observed — Web mutations retain manage_options and action-nonce enforcement. CLI loading requires WP_CLI to be defined and true; CLI mutations do not apply WordPress user-capability checks. Their boundary is local CLI execution authority, while disconnect confirmation protects against accidental execution rather than authenticating the operator.

Resilience and Maintainability Implications

  • observed — The wait loop treats blocked delivery, disconnection, failed activation and a stopped export as errors instead of reporting successful deployment. Production activation requires a ready version marked current production; completion also checks the requested generation and remaining inline queue.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat: add wp spacefast WP-CLI commands" names the main change. The changeset adds a wp spacefast WP-CLI command with status, publish, build, sync-settings, and disconnect operations, alon…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat: add wp spacefast WP-CLI commands" names the main change. The changeset adds a wp spacefast WP-CLI command with status, publish, build, sync-settings, and disconnect operations, along with supporting refactors, a version bump, and docs. The title is short, specific, and in one sentence, and it matches the primary objective in the PR summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 92e96af8-5176-4aff-9970-34adce07282d
Commits

Reviewing files that changed from the base of the PR and between 04f0854 and e1aeed3.

Files selected for processing: 9

  • README.md
  • bin/test-wordpress.sh
  • includes/class-spacefast-cli-export-job.php
  • includes/class-spacefast-cli.php
  • includes/class-spacefast-plugin.php
  • readme.txt
  • spacefast-wordpress.php
  • tests/acceptance/wordpress.php
  • tests/behavior.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant